package com.example.service;

import org.springframework.stereotype.Service;

@Service
public class UserService {

    // 模拟执行耗时的业务方法
    public String getUserInfo(String userId) {
        try {
            // 模拟方法执行耗时
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "User info for: " + userId;
    }

    // 模拟抛出异常的业务方法
    public String getUserInfoWithException(String userId) {
        if (userId.equals("error")) {
            throw new IllegalArgumentException("User ID is invalid!");
        }
        return "User info for: " + userId;
    }
}
